package com.voute.View.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.voute.Model.Bean.ChannelResourceEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * 频道搜索出来的数据展示在GridView中，与之对应的Adapter
 * Created by liukanshan on 2016/12/26.
 */

public class ChannelResourceAdapter extends BaseAdapter {

    private List<ChannelResourceEntity> datas = new ArrayList<>();
    private Context mContext;

    public ChannelResourceAdapter(Context context, List<ChannelResourceEntity> entities) {
        if (entities != null) {
            datas.clear();
            datas.addAll(entities);
        }
        mContext = context;
    }

    public void setDatas(List<ChannelResourceEntity> entities) {
        if (entities != null) {
            datas.clear();
            datas.addAll(entities);
            notifyDataSetChanged();
        }
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
//        if (convertView == null) {
//            convertView = View.inflate(mContext, R.layout.adapter_channel_res, null);
//        }
//        initView(position, convertView);
        return convertView;
    }

    private void initView(int position, View convertView) {
//        ChannelResourceEntity entity = datas.get(position);
//        ImageView adapter_hot_imager = ViewHolderUtils.get(convertView, R.id.adapter_hot_imager);
//        GlideUtils.getInstance().LoadSimpleContextRoundBitmap(mContext, entity.getPoster(), adapter_hot_imager, DisplayUtil.px2dip(mContext, 14));
//        TextView adapter_hot_title = ViewHolderUtils.get(convertView, R.id.adapter_hot_title);
//        adapter_hot_title.setText(entity.getCnname());
//        TextView adapter_en_name = ViewHolderUtils.get(convertView, R.id.adapter_en_name);
//        adapter_en_name.setText(entity.getEnname());
//        TextView resource_desc = ViewHolderUtils.get(convertView, R.id.resource_desc);
//        resource_desc.setText("说明：" + entity.getRemark());
//        TextView resource_type = ViewHolderUtils.get(convertView, R.id.resource_type);
//        resource_type.setText("类型：" + entity.getCategory());
//        TextView resource_score = ViewHolderUtils.get(convertView, R.id.resource_score);
//        resource_score.setText("评分：" + entity.getScore());
    }
}
